import type { ResponseData } from '@/utils/request';
import { SUCCESS_CODE } from '@/utils/request';
import type { RequestData } from '@ant-design/pro-table';
import { message } from 'antd';
import { request, useModel } from 'umi';
import type { orderList, QueryParams } from './types';

//查询单个数据
export async function getOrderDetail(id?: string) {
  return await request(`/parking/${id}`);
}

//获取优惠券列表数据
export async function getOrderTable(params: QueryParams): Promise<RequestData<orderList>> {
  return await request('/coupon/get_coupon_list', {
    params: {
      ...params,
      page: params.current,
      pageSize: params.pageSize,
      // beginTime   endTime
      startArrivedDate: params.beginTime && params.beginTime[0],
      endArrivedDate: params.beginTime && params.beginTime[1],
      startLeaveDate: params.endTime && params.endTime[0],
      endLeaveDate: params.endTime && params.endTime[1],

      // tenant_id: params.tenant ? params.tenant?.id : '',
    },
  });
}

//获取优惠券模板下的优惠券数据
export async function optionsSchemeItem(params: {
  status: number;
  templateId: string;
  page: number;
  pageSize: number;
}): Promise<ResponseData<any>> {
  return await request('/coupon/template/coupon/list', {
    params: {
      ...params,
    },
  });
}
